<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>员工列表练习</title>
</head>
<body>
<center>
<input type="text" placeholder="员工姓名">
<input type="text" placeholder="工资">
<input type="text" placeholder="工作">
<input type="button" value="添加">
    <table border="1">
        <caption>员工列表</caption>
        <tr>
            <th>姓名</th>
            <th>工资</th>
            <th>工作</th>
            <th>操作</th>
        </tr>
    </table>
</center>


<script src="https://cdn.staticfile.org/jquery/2.1.1/jquery.min.js"></script>
<script>
    $("input:last").click(function () {
        let tr = $("<tr></tr>");
        let nametd = $("<td></td>");
        let saltd = $("<td></td>");
        let jobtd = $("<td></td>");
        let deltd = $("<td><input type='button' value='删除'></td>");
        deltd.children().click(function () {
            tr.remove();
        });
        //给td设置显示的文本
        nametd.text($("input:eq(0)").val());
        saltd.text($("input:eq(1)").val());
        jobtd.text($("input:eq(2)").val());
        //把td装进tr,把tr装进table
        tr.append(nametd);
        tr.append(saltd);
        tr.append(jobtd);
        tr.append(deltd);
        $("table").append(tr);
    });

</script>
</body>
</html>